//权限的指令的映射
const TYPES = {
  query:0, //查询
  add:1, //添加
  delete:2, //删除
  update:4 //更新
}

export default {
  inserted (el, binding) {
    const arg = binding.arg // route里面返回的指令
    const opt = TYPES[binding.arg]
    const route = binding.value
    // console.log(binding)
    // console.log(arg, opt)
    if(route.matched.some( item => {
      item.meta.scope && item.meta.scope.includes(opt)} )){
      console.log('没有'+arg+'权限,已限制其渲染!')
      el.parentNode.removeChild(el)
    }else{
      // console.log('有'+arg+'权限!')
    }
  }
}